package cn.mf.hrm.controller;

import cn.mf.hrm.doc.CourseDoc;
import cn.mf.hrm.dto.CourseESQuery;
import cn.mf.hrm.service.ICourseESService;
import cn.mf.hrm.util.AjaxResult;
import cn.mf.hrm.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//课程保存到ES中
@RequestMapping("/es/course")
@RestController
public class CourseESController {

    @Autowired
    private ICourseESService courseESService;
    /**
     * 添加课程
     * @param courseDoc
     * @return
     */
    @PostMapping("/save")
    // 接受的是一个对象
    public AjaxResult save(@RequestBody CourseDoc courseDoc){
        courseESService.save(courseDoc);
        return AjaxResult.me();
    }

    /**
     * 查询课程
     */
    @PostMapping("/search")
    public AjaxResult search(@RequestBody CourseESQuery query){
        PageList pageList = courseESService.search(query);
        return AjaxResult.me().setResultObj(pageList);
    }

}
